<template>
  <el-card shadow="always" :wbody-style="{ padding: '20px' }">
    <Find :OriginalFilter="{ static: true }" :formList="formList" />
    <Table :tableData="tableData" :tableHeader="tableHeader" :TableHeight="'250rem'" stripe @currentRow="CurrentRow" />
    <PageModule :PageData="{ total: 500 }" />
    <el-button type="primary" size="default" @click="output">导出</el-button>
    <el-button type="primary" size="default" @click="message">111111</el-button>
  </el-card>
</template>
<script lang="ts">
import type { formListType } from '@/components/Find/index.vue'
import { defineComponent, onMounted, ref } from 'vue'
import Jian from '@/utils/Jian'
import { sse } from '@/utils/sse'
import { ElMessage, ElMessageBox } from 'element-plus'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'Test1'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import { TableList } from '@/plugins/mixin'
import Api from '@/api/GeneralManager/inquire/AggregateSchedulingLi'
import type { TableListType } from '@/api/GeneralManager/inquire/OrderSummary'
import PageModel from '@/components/PageModule/PageModule.vue'
const srcList = ref([])
const output = () => {
  sse()
}
const message = () => {
  let messageBoxTimer: any
  let countdown = 10 // 秒数
  ElMessageBox({
    showCancelButton: true,
    showConfirmButton: false,
    dangerouslyUseHTMLString: true,
    title: '系统提示',
    message: `系统有更新，将在10秒后自动更新`,
    type: 'warning',
    customClass: 'soleClass'
  })
    .then(() => {
      if (messageBoxTimer) clearInterval(messageBoxTimer)
      // 这里是 点击取消的操作（按钮位置调换）
    })
    .catch((action) => {
      console.log(22222)
      if (messageBoxTimer) clearInterval(messageBoxTimer)
    })
  messageBoxTimer = setInterval(() => {
    // 获取demo元素 因为页面可能有多个提示  加唯一标识 soleClass 修改内容
    const domeInfo = document.querySelector('.soleClass .el-message-box__btns')
    if (domeInfo) {
      domeInfo.querySelectorAll('.confirm')?.forEach((item) => {
        item.remove()
      })
      domeInfo.insertAdjacentHTML(
        'beforeend',
        `<button class="confirm el-button el-button--primary el-button--default" onclick="window.location.reload()">确认${countdown}</button>`
      )
    }
    if (countdown <= 1) {
      if (messageBoxTimer) clearInterval(messageBoxTimer)
      countdown = 10
      // 倒计时结束 执行事件
      window.location.reload()
      ElMessageBox.close() // 关闭弹框
      return
    }
    countdown -= 1
  }, 1000)
}
const tableHeader = ref([
  {
    label: '安排日期',
    prop: 'scheduleNo'
  },
  {
    label: '生产线',
    prop: 'line'
  },
  {
    label: '序号',
    prop: 'seqNo'
  },
  {
    label: '指令',
    prop: 'lotNO',
    width: '160'
  },
  {
    label: '样品类型',
    prop: 'sampleType'
  },
  {
    label: '工厂货号',
    prop: 'style'
  },
  {
    label: '颜色',
    prop: 'color'
  },
  {
    label: '订单量',
    prop: 'orderQty'
  },
  {
    label: '交期',
    prop: 'deliveryDate'
  },
  {
    label: '安排数量',
    prop: 'scheduleQty'
  },
  {
    label: 'IE日产能',
    prop: 'stdQty'
  },
  {
    label: '生产天数',
    prop: 'prodDays'
  },
  {
    label: '开始日期',
    prop: 'beginDate'
  },
  {
    label: '结束日期',
    prop: 'endDate'
  },
  {
    type: 'img',
    prop: 'stylePhoto',
    label: '图片',
    fixed: true,
    srcList
  }
])
// const tableData = ref([
//   {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',

//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img2.baidu.com/it/u=1997319467,2330526178&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=666',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img2.baidu.com/it/u=1405292603,3599771060&fm=253&fmt=auto&app=120&f=JPEG?w=700&h=1050',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F269531c4-307b-4847-b132-0f09be4b4db1%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1691563749&t=2b753e7ea78ee3a0f9872f4645d7ad31',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   }, {
//     img: 'https://img1.baidu.com/it/u=413643897,2296924942&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
//     instruction: '指令',
//     cargoNumber: '货号',
//     sampleType: '样品类型',
//     brand: '品牌',
//     season: '季节',
//     customerDeliveryDate: '客户交期',
//     orderDate: '下单日期',
//     deliveryDate: '出货日期',
//     completion: '完成情况',
//     remarks: '备注',
//   },
// ])

const tableData = ref([])
const formList = ref<any>([
  {
    type: 'select',
    selectValue: '',
    selectP: '生产线',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '货号',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'date',
    dateLabel: '交期',
    dateValue: ''
  },
  {
    type: 'date',
    dateLabel: '开始日期',
    dateValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '清空'
  },
  {
    type: 'button',
    checkboxLabel: '导出'
  }
])
const CurrentRow = () => {}
const currentPage = ref(1)
const pageSize = ref(20)
const summaryData = ref([
  {
    index: 11,
    num: 0
  },
  {
    index: 7,
    num: 0
  }
])
onMounted(async () => {
  // const res = await Jian.get('/show/prod/blank/cpc')
  // console.log(res)
  // let Data = await TableList(formList, Api.getTableList, currentPage, pageSize) as TableListType
  // tableData.value = Data.list
  // if (Data.list) {
  //   let dataList: any = Data.list.map((item: any) => {
  //     item.seqNo = parseFloat(item.seqNo).toFixed(2)
  //     item.orderQty = parseFloat(item.orderQty).toFixed(2)
  //     item.prodDays = parseFloat(item.prodDays).toFixed(2)
  //     return item
  //   })
  //   // console.log(Data);
  //   srcList.value = dataList.map((item: any) => {
  //     return item.stylePhoto
  //   })
  // }
})
</script>

<style lang="less"></style>
